package com.fegin.client.admin;

import com.fegin.Hystrix.admin.UserFigenHystrix;
import com.fegin.bean.admin.AdminUser;
import com.fegin.bean.common.layuiBean.ResultPage;
import com.fegin.bean.common.layuiBean.VoPage;
import com.fegin.common.ServerNameConstant;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * @author 张子艺
 * @packge com.fegin.client
 * @data 2019-01-15 16:39
 * @project currencycloud
 */

//微服务名字                         熔断器
@FeignClient(value = ServerNameConstant.ADMIN_SERVER ,fallbackFactory = UserFigenHystrix.class)
public interface UserFegin {
    @RequestMapping(value = "/admin/user/login",
            method = RequestMethod.GET
    )
    AdminUser login(@RequestParam("userName") String userName, @RequestParam("passWord") String passWord);


    @RequestMapping(value = "/admin/user/findUser",
            method = RequestMethod.POST,
            consumes = MediaType.APPLICATION_JSON_VALUE
    )
    ResultPage<AdminUser> findUser(@RequestBody VoPage voPage ,@RequestParam("loginId") Long loginId);

    /**
     * 查询分销商用户
     * @param voPage
     * @return
     */
    @RequestMapping(value = "/admin/user/findDistributionPeoPleByPage",
            method = RequestMethod.POST,
            consumes = MediaType.APPLICATION_JSON_VALUE
    )
    ResultPage<AdminUser> findDistributionPeoPleByPage(@RequestBody VoPage voPage);


    @RequestMapping(value = "/admin/user/insertUser",
            method = RequestMethod.POST,
            consumes = MediaType.APPLICATION_JSON_VALUE
    )
    Map<String, Object> insertUser(@RequestBody AdminUser user, @RequestParam("roleId") Long roleId, @RequestParam("loginId") Long loginId);


    @RequestMapping(value = "/admin/user/delUser",
            method = RequestMethod.POST,
            consumes = MediaType.APPLICATION_JSON_VALUE
    )
    Map<String, Object> delUser(@RequestParam("userId") Long userId, @RequestParam("userName") String userName);

}
